import 'package:flutter/material.dart';

import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';

class myTast extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => myTastState();
}
class myTastState extends State<myTast> {
  var _storageString = new Map();
  var currentVideoUrl;

  /**
   * 获取存在SharedPreferences中的数据
   */
  Future getString() async {
    SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
    String currentVideoData = sharedPreferences.getString('current_video');
    Map<String, dynamic> temObjData = await json.decode(currentVideoData);
    setState(() {
      _storageString = temObjData;
      currentVideoUrl = temObjData['videoUrl'];
    });
  }

  @override
  void initState() {

    super.initState();
    getString();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
        backgroundColor: Colors.deepOrange,
        elevation: 0.0,
        title: new Text(
          "云测验",
          style: new TextStyle(
              color: Colors.white,
              fontSize: 18.0,
              fontWeight: FontWeight.normal),
        ),
      ),
      body: new Column(
        children: <Widget>[
          Text('${_storageString}')
        ],
      ),
    );
  }
}